package com.springcloud.utils;

import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public class ListUtil {
    @NotNull
    @Contract("null -> new")
    public static <T>List<T> reverseList(List<T> list){
        List<T> listReverse=new ArrayList<>();
        if (list != null && list.size() > 0) {
            for (int i = 1; i <= list.size(); i++) {
                listReverse.add(list.get(list.size() - i));
            }
            return  listReverse;
        }
        return  new ArrayList<>();
    }
}
